using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using ZedGraph;

namespace ICP_MS.Plugin.HPLC;

public class FormScan : Form
{
	private ExperimentDatas experiment = null;

	private ExperimentDB db = null;

	private List<HPLCIntegerRegions> regions = new List<HPLCIntegerRegions>();

	private IsotopeInfos selectIsotope = null;

	private SamplesInfos selectSample = null;

	private HPLCIntegerRegions region = null;

	private new bool RegionChanged = false;

	private List<GraphPane> paneList = new List<GraphPane>();

	private IContainer components = null;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn13;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn14;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn16;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn17;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn18;

	private GroupBox groupBox1;

	private TreeView treeView1;

	private GroupBox groupBox2;

	private DataGridView dgvRegions;

	private GroupBox groupBox3;

	private DataGridView dgvPeak;

	private DataGridViewTextBoxColumn colSymbol;

	private DataGridViewTextBoxColumn colDwell;

	private DataGridViewTextBoxColumn colResolution;

	private DbufferGrid dgvSample;

	private DataGridViewTextBoxColumn ColSampleName;

	private DataGridViewTextBoxColumn colTimes;

	private DataGridViewTextBoxColumn colSweeps;

	private TableLayoutPanel tableLayoutPanel2;

	private Panel panel1;

	private ToolStrip toolStrip1;

	private ToolStripButton tsbtnAutoPeak;

	private ToolStripButton tsbtnManualPeak;

	private ToolStripButton tsbtnRestore;

	private ToolStripButton tsbtnShowPoints;

	private ToolStripButton tsbtnCopy;

	private DataGridViewTextBoxColumn colLabel;

	private DataGridViewTextBoxColumn ColPeakPosition;

	private DataGridViewTextBoxColumn colStart;

	private DataGridViewTextBoxColumn colEnd;

	private DataGridViewTextBoxColumn colReference;

	private DataGridViewTextBoxColumn clPeakArea;

	private DataGridViewTextBoxColumn ColPeakValue;

	private CustomGraph customGraph1;

	public FormScan()
	{
		InitializeComponent();
	}

	public void SetParams(ExperimentDatas experiment, ExperimentDB db)
	{
		this.experiment = experiment;
		this.db = db;
	}

	private void FormScan_Load(object sender, EventArgs e)
	{
		ApplyResources();
		base.WindowState = FormWindowState.Maximized;
		GraphPane pane = customGraph1.GraphPane;
		pane.Legend.Position = LegendPos.Right;
		pane.Title.Text = "";
		pane.XAxis.Title.Text = "Time/s";
		pane.XAxis.Scale.Min = 0.0;
		pane.XAxis.Scale.Max = 300.0;
		pane.YAxis.Title.Text = "Intensity/CPS";
		pane.Chart.Border.IsVisible = false;
		pane.XAxis.MinorTic.IsOpposite = false;
		pane.XAxis.MajorTic.IsOpposite = false;
		pane.YAxis.MajorTic.IsOpposite = false;
		pane.YAxis.MinorTic.IsOpposite = false;
		customGraph1.IsShowContextMenu = false;
		customGraph1.GraphPane.XAxis.Scale.MaxAuto = false;
		pane.AxisChange();
		customGraph1.Refresh();
		CustomGraph.RegionChanged = (EventHandler)Delegate.Combine(CustomGraph.RegionChanged, new EventHandler(SelectRegionChanged));
		experiment_isotopeChanged(null, null);
		experiment_sampleChanged(null, null);
		experiment.SingleAcq += experiment_SingleAcq;
		experiment.EventExperiment += experiment_EventExperiment;
		experiment.isotopeChanged += experiment_isotopeChanged;
		experiment.sampleChanged += experiment_sampleChanged;
	}

	private void SelectRegionChanged(object sender, EventArgs e)
	{
		if (regions.Exists((HPLCIntegerRegions r) => r.ReferenceId == customGraph1.selectRegion.ReferenceId))
		{
			HPLCIntegerRegions region = regions.Find((HPLCIntegerRegions r) => r.ReferenceId == customGraph1.selectRegion.ReferenceId);
			region.Start = customGraph1.selectRegion.Start;
			region.End = customGraph1.selectRegion.End;
			IEnumerable<HPLCTimeSpectrum> spectrum = experiment.TimeSpectrums.Where((HPLCTimeSpectrum specs) => specs.SampleId == selectSample.guid && specs.Symbol == selectIsotope.symbol);
			if (spectrum != null && spectrum.Count() > 0)
			{
				region.Startindex = spectrum.First().Time.FindIndex((double r) => r.Equals(region.Start));
				region.EndIndex = spectrum.First().Time.FindIndex((double r) => r.Equals(region.End));
				if (region.Startindex >= 0 && region.EndIndex >= 0)
				{
					region.Area = CalculateIntegerValue(spectrum.First().Time.ToArray(), spectrum.First().Intensity.ToArray(), region.Startindex, region.EndIndex);
					region.PositionIndex = FindPeak(spectrum.First().Intensity.ToArray(), region.Startindex, region.EndIndex);
					region.Peak = spectrum.First().Intensity[region.PositionIndex];
					region.PeakPostion = spectrum.First().Time[region.PositionIndex];
				}
			}
			UpdateRegionGraph();
			dgvRegions.Refresh();
		}
		tsbtnManualPeak.Checked = false;
	}

	private int FindPeak(double[] v, int start, int end)
	{
		int index = -1;
		double max = v[start];
		for (int i = start + 1; i < end; i++)
		{
			if (v[i] > max)
			{
				max = v[i];
				index = i;
			}
		}
		return index;
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("HPLC.FormScan.Title.Text");
		groupBox1.Text = Lang.Txt("HPLC.FormScan.GroupBox.ScanParam.Text");
		groupBox2.Text = Lang.Txt("HPLC.FormScan.GroupBox.Integration.Text");
		groupBox3.Text = Lang.Txt("HPLC.FormScan.GroupBox.ScanParam.Text");
		colDwell.HeaderText = Lang.Txt("HPLC.FormScan.Columns.DwellTime.Text");
		colEnd.HeaderText = Lang.Txt("HPLC.FormScan.Columns.End.Text");
		colLabel.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Label.Text");
		colResolution.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Resolution.Text");
		colStart.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Start.Text");
		colSweeps.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Times.Text");
		colSymbol.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Element.Text");
		ColSampleName.HeaderText = Lang.Txt("HPLC.FormScan.Columns.Sample.Text");
		colTimes.HeaderText = Lang.Txt("HPLC.FormScan.Columns.SampleTime.Text");
		ColPeakPosition.HeaderText = Lang.Txt("FormScanLA.KeepTime");
		clPeakArea.HeaderText = Lang.Txt("FormScanLA.PeakArea");
		ColPeakValue.HeaderText = Lang.Txt("FormScanLA.PeakHeight");
		tsbtnAutoPeak.Text = Lang.Txt("FormScanLA.Text4");
		tsbtnManualPeak.Text = Lang.Txt("FormScanLA.Text5");
		tsbtnRestore.Text = Lang.Txt("FormScanLA.Text6");
		tsbtnShowPoints.Text = Lang.Txt("FormScanLA.Text7");
		tsbtnCopy.Text = Lang.Txt("FormScanLA.Text8");
	}

	private void experiment_SingleAcq(object sender, CurveInfoEventArgs e)
	{
		UpdateCurves(e.SampleId, e.RunIndex);
	}

	private void experiment_EventExperiment(object sender, ExperimentEventArgs e)
	{
		if (e.StepIndex != 0)
		{
			return;
		}
		SamplesInfos sample = e.Sample;
		foreach (TreeNode node in treeView1.Nodes)
		{
			if (node.Tag == sample)
			{
				Invoke((MethodInvoker)delegate
				{
					treeView1.SelectedNode = node;
				});
				break;
			}
		}
	}

	private void experiment_isotopeChanged(object sender, EventArgs e)
	{
		UpdatePeakJumpRegions(null, null);
		SetSampleIsotopes();
	}

	private void experiment_sampleChanged(object sender, EventArgs e)
	{
		SetSampleIsotopes();
		RebindAcqTime();
	}

	private void FormScan_FormClosing(object sender, FormClosingEventArgs e)
	{
		experiment.sampleChanged -= experiment_sampleChanged;
		experiment.isotopeChanged -= experiment_isotopeChanged;
		experiment.SingleAcq -= experiment_SingleAcq;
		experiment.EventExperiment -= experiment_EventExperiment;
	}

	private void RebindPeakData()
	{
		experiment.PeakRegions.Sort((PeakRegions r1, PeakRegions r2) => r1.mass.CompareTo(r2.mass));
		dgvPeak.AutoGenerateColumns = false;
		if (dgvPeak.DataSource == null)
		{
			dgvPeak.DataSource = experiment.PeakRegions;
			return;
		}
		BindingContext[dgvPeak.DataSource].SuspendBinding();
		dgvPeak.DataSource = null;
		dgvPeak.DataSource = experiment.PeakRegions;
		BindingContext[dgvPeak.DataSource].ResumeBinding();
	}

	private void RebindAcqTime()
	{
		((DataGridView)(object)dgvSample).AutoGenerateColumns = false;
		if (((DataGridView)(object)dgvSample).DataSource == null)
		{
			((DataGridView)(object)dgvSample).DataSource = experiment.AcqTimes;
			return;
		}
		BindingContext[((DataGridView)(object)dgvSample).DataSource].SuspendBinding();
		((DataGridView)(object)dgvSample).DataSource = null;
		((DataGridView)(object)dgvSample).DataSource = experiment.AcqTimes;
		BindingContext[((DataGridView)(object)dgvSample).DataSource].ResumeBinding();
	}

	private void SetPeakJumpRegions()
	{
		List<PeakRegions> removeregions = new List<PeakRegions>();
		foreach (PeakRegions peakregion2 in experiment.PeakRegions)
		{
			if (experiment.Isotopes.Find((IsotopeInfos isotope) => isotope.mass == peakregion2.mass) == null)
			{
				removeregions.Add(peakregion2);
			}
		}
		for (int i = 0; i < removeregions.Count; i++)
		{
			experiment.PeakRegions.Remove(removeregions[i]);
		}
		foreach (IsotopeInfos isotope2 in experiment.Isotopes)
		{
			if (experiment.PeakRegions.Find((PeakRegions peakregion) => peakregion.symbol == isotope2.symbol) == null)
			{
				if (experiment.PeakRegions.Count > 0)
				{
					experiment.PeakRegions.Add(new PeakRegions(isotope2.symbol, isotope2.mass, experiment.PeakRegions[0].dwell, experiment.PeakRegions[0].channels));
				}
				else
				{
					experiment.PeakRegions.Add(new PeakRegions(isotope2.symbol, isotope2.mass));
				}
			}
		}
		experiment.PeakRegions.Sort((PeakRegions a, PeakRegions b) => a.mass.CompareTo(b.mass));
	}

	private void UpdatePeakJumpRegions(object sender, EventArgs e)
	{
		SetPeakJumpRegions();
		RebindPeakData();
	}

	private void RebindIntegRegions()
	{
		dgvRegions.AutoGenerateColumns = false;
		if (dgvRegions.DataSource == null)
		{
			dgvRegions.DataSource = regions;
			return;
		}
		BindingContext[dgvRegions.DataSource].SuspendBinding();
		dgvRegions.DataSource = null;
		dgvRegions.DataSource = regions;
		BindingContext[dgvRegions.DataSource].ResumeBinding();
	}

	private void SetSampleIsotopes()
	{
		treeView1.Nodes.Clear();
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			TreeNode node = treeView1.Nodes.Add(isotope.symbol);
			node.Tag = isotope;
			foreach (SamplesInfos sample in experiment.Samples)
			{
				TreeNode subNode = node.Nodes.Add(sample.label);
				subNode.Tag = sample;
			}
		}
	}

	private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
	{
		if (e.Node.Equals(treeView1.Nodes[0]))
		{
			selectSample = null;
			selectIsotope = null;
		}
		else if (e.Node.Level == 0)
		{
			selectSample = null;
			selectIsotope = e.Node.Tag as IsotopeInfos;
		}
		else
		{
			selectIsotope = e.Node.Parent.Tag as IsotopeInfos;
			selectSample = e.Node.Tag as SamplesInfos;
		}
		SetNodeColor(treeView1.Nodes, e.Node);
		SetIntegRegion();
		SetupCurves();
		UpdateCurves();
	}

	private void SetNodeColor(TreeNodeCollection nodes, TreeNode destNode)
	{
		foreach (TreeNode child in nodes)
		{
			if (child.Equals(destNode))
			{
				child.BackColor = Color.FromKnownColor(KnownColor.Highlight);
			}
			else
			{
				child.BackColor = Color.White;
			}
			if (child.Nodes.Count > 0)
			{
				SetNodeColor(child.Nodes, destNode);
			}
		}
	}

	private void SetIntegRegion()
	{
		regions.Clear();
		if (selectIsotope != null && selectSample != null)
		{
			IEnumerable<HPLCIntegerRegions> tRegions = experiment.IntegerRegions.Where((HPLCIntegerRegions region) => region.symbol == selectIsotope.symbol && region.sampleId == selectSample.guid);
			if (tRegions.Any())
			{
				regions.AddRange(tRegions);
			}
		}
		RebindIntegRegions();
		customGraph1.SetRegions(regions.ToArray());
	}

	private void UpdateRegionGraph()
	{
		customGraph1.SetRegions(regions.ToArray());
		customGraph1.Refresh();
	}

	private void dgvRegions_MouseDown(object sender, MouseEventArgs e)
	{
		if (e.Button != MouseButtons.Right || (selectIsotope == null && selectSample == null))
		{
			return;
		}
		ContextMenu menu = new ContextMenu();
		menu.MenuItems.Add(Lang.Txt("FormScan.Add.Text"), delegate
		{
			string text = Convert.ToString(Guid.NewGuid());
			foreach (SamplesInfos current in experiment.Samples)
			{
				HPLCIntegerRegions hPLCIntegerRegions = new HPLCIntegerRegions
				{
					Peak = -1.0,
					Area = -1.0,
					PeakPostion = -1.0,
					Start = -1.0,
					End = -1.0,
					Label = text,
					ReferenceId = text
				};
				hPLCIntegerRegions.IsotopeId = selectIsotope.id;
				hPLCIntegerRegions.symbol = selectIsotope.symbol;
				hPLCIntegerRegions.sampleId = current.guid;
				experiment.IntegerRegions.Add(hPLCIntegerRegions);
				if (selectSample != null && selectSample.guid == current.guid)
				{
					regions.Add(hPLCIntegerRegions);
					experiment.SetupResultsByAddIntegerRegions(hPLCIntegerRegions);
				}
			}
			RebindIntegRegions();
			UpdateRegionGraph();
			experiment.OnRegionChanged();
		});
		menu.MenuItems.Add(Lang.Txt("FormScan.Delete.Text"), delegate
		{
			List<HPLCIntegerRegions> list = new List<HPLCIntegerRegions>();
			foreach (DataGridViewRow dataGridViewRow in dgvRegions.SelectedRows)
			{
				list.Add(regions[dataGridViewRow.Index]);
			}
			foreach (HPLCIntegerRegions region in list)
			{
				experiment.IntegerRegions.RemoveAll((HPLCIntegerRegions r) => r.Label == region.Label);
				regions.Remove(region);
				experiment.SetupResultsByDeleteIntegerRegions(region);
			}
			list.Clear();
			list = null;
			RebindIntegRegions();
			UpdateRegionGraph();
			experiment.OnRegionChanged();
		});
		menu.MenuItems.Add("应用到所有样品", delegate
		{
			if (selectIsotope != null && selectSample != null)
			{
				experiment.ApplyRegioninAllSamples(selectSample, selectIsotope);
			}
		});
		menu.Show(dgvRegions, e.Location);
	}

	private void dgvRegions_CellValueChanged(object sender, DataGridViewCellEventArgs e)
	{
		if (e.RowIndex < 0)
		{
			return;
		}
		switch (e.ColumnIndex)
		{
		case 0:
		{
			string name = Convert.ToString(dgvRegions.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
			string referencesId = Convert.ToString(dgvRegions.Rows[e.RowIndex].Cells["colReference"].Value);
			IEnumerable<HPLCIntegerRegions> res = experiment.IntegerRegions.Where((HPLCIntegerRegions ress) => ress.ReferenceId == referencesId);
			foreach (HPLCIntegerRegions re in res)
			{
				re.Label = name;
			}
			experiment.OnRegionChanged();
			UpdateRegionGraph();
			break;
		}
		case 1:
		case 2:
			UpdateRegionGraph();
			break;
		}
	}

	private void SetupCurves()
	{
		if (selectSample == null)
		{
			return;
		}
		MasterPane masterPane = customGraph1.MasterPane;
		masterPane.PaneList.Clear();
		for (int i = 0; i < selectSample.mains; i++)
		{
			GraphPane pane = new GraphPane();
			pane.Title.Text = selectSample.label;
			pane.Title.Text = $"{selectSample.label}";
			pane.Title.FontSpec.Size = 16f;
			pane.XAxis.Scale.Min = 0.0;
			pane.XAxis.Title.Text = "时间/s";
			pane.YAxis.Title.Text = "强度/CPS";
			pane.Chart.Border.IsVisible = false;
			pane.XAxis.MinorTic.IsOpposite = false;
			pane.XAxis.MajorTic.IsOpposite = false;
			pane.YAxis.MajorTic.IsOpposite = false;
			pane.YAxis.MinorTic.IsOpposite = false;
			pane.XAxis.Scale.MaxAuto = true;
			IEnumerable<AcqTime> acqinfo = experiment.AcqTimes.Where((AcqTime ai) => ai.SampleId == selectSample.guid);
			if (acqinfo != null && acqinfo.Count() > 0)
			{
				pane.XAxis.Scale.Max = acqinfo.First().Time;
			}
			else
			{
				pane.XAxis.Scale.Max = 140.0;
			}
			pane.Legend.FontSpec.Size = 12f;
			pane.IsFontsScaled = true;
			if (selectIsotope != null)
			{
				LineItem line = pane.AddCurve(selectIsotope.symbol, new PointPairList(), Color.Black, SymbolType.None);
				line.Line.Width = 2f;
				line.Tag = selectIsotope.symbol;
			}
			else
			{
				int colorCount = 0;
				foreach (IsotopeInfos isotope in experiment.Isotopes)
				{
					LineItem line2 = pane.AddCurve(isotope.symbol, new PointPairList(), Color.FromKnownColor((KnownColor)(141 + colorCount++)), SymbolType.None);
					line2.Tag = isotope.symbol;
					line2.Line.Width = 2f;
				}
			}
			masterPane.PaneList.Add(pane);
		}
		Graphics g = customGraph1.CreateGraphics();
		masterPane.SetLayout(g, PaneLayout.SingleRow);
		masterPane.AxisChange();
		g.Dispose();
		customGraph1.Refresh();
	}

	private void UpdateCurves(int sampleIdx, int runIdx)
	{
		if (selectSample == null || selectSample.guid != sampleIdx || selectSample.mains <= runIdx)
		{
			return;
		}
		GraphPane pane = customGraph1.MasterPane.PaneList[runIdx];
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			CurveItem lineItem = pane.CurveList.Find((CurveItem line) => line.Tag.Equals(isotope.symbol));
			if (lineItem == null)
			{
				continue;
			}
			IEnumerable<HPLCTimeSpectrum> spectrums = experiment.TimeSpectrums.Where((HPLCTimeSpectrum spectrum) => spectrum.SampleId == selectSample.guid && spectrum.Symbol == isotope.symbol && spectrum.RunIndex == runIdx);
			if (spectrums.Any())
			{
				HPLCTimeSpectrum spectrum2 = spectrums.First();
				lock (spectrum2)
				{
					lineItem.Points = new PointPairList(spectrum2.Time.ToArray(), spectrum2.Intensity.ToArray());
				}
			}
		}
		pane.AxisChange();
		Invoke((MethodInvoker)delegate
		{
			customGraph1.Refresh();
		});
	}

	private void UpdateCurves()
	{
		if (selectSample != null)
		{
			for (int i = 0; i < selectSample.mains; i++)
			{
				UpdateCurves(selectSample.guid, i);
			}
		}
	}

	private void tsbtnAutoPeak_Click(object sender, EventArgs e)
	{
		double minpeak = 0.0;
		double minArea = 0.0;
		double threshold = 0.0;
		double peakwidth = 0.0;
		FormPeakSet formPeakSet = new FormPeakSet();
		if (formPeakSet.ShowDialog() != DialogResult.OK)
		{
			return;
		}
		minpeak = formPeakSet.minPeak;
		minArea = formPeakSet.minArea;
		peakwidth = formPeakSet.minPeakWidth;
		threshold = formPeakSet.threshold;
		if (selectSample == null || selectIsotope == null || selectSample.guid != selectSample.guid || selectSample.mains <= 0)
		{
			return;
		}
		IEnumerable<HPLCTimeSpectrum> spectrums = experiment.TimeSpectrums.Where((HPLCTimeSpectrum spectrum) => spectrum.SampleId == selectSample.guid && spectrum.Symbol == selectIsotope.symbol && spectrum.RunIndex == 0);
		if (spectrums.Any())
		{
			HPLCTimeSpectrum spectrum2 = spectrums.First();
			List<double> spectrumY = new List<double>();
			List<double> spectrumTemp = new List<double>();
			spectrumTemp = InterferenceCorrection.smooth(spectrum2.Intensity.ToArray(), SmoothType.FivePointsSmooth, 2);
			spectrumY = spectrumTemp;
			List<PeakInfo> peakaddress = new List<PeakInfo>();
			peakaddress = InterferenceCorrection.findPeak(spectrum2.Time.ToArray(), spectrumY.ToArray(), FindPeakType.Comparison, minpeak, minArea, threshold, peakwidth).ToList();
			for (int i = 0; i < peakaddress.Count; i++)
			{
				regions[i].Start = peakaddress[i].start;
				regions[i].End = peakaddress[i].end;
				regions[i].Startindex = peakaddress[i].startindex;
				regions[i].EndIndex = peakaddress[i].endindex;
				regions[i].PeakPostion = peakaddress[i].position;
				regions[i].PositionIndex = peakaddress[i].positionindex;
				regions[i].Area = CalculateIntegerValue(spectrum2.Time.ToArray(), spectrum2.Intensity.ToArray(), regions[i].Startindex, regions[i].EndIndex);
				regions[i].Peak = spectrum2.Intensity[regions[i].PositionIndex];
			}
			customGraph1.Refresh();
			dgvRegions.Refresh();
		}
	}

	private double CalculateIntegerValue(double[] time, double[] intensity, int start, int end)
	{
		if (time == null || end == start)
		{
			return 0.0;
		}
		double sum = 0.0;
		for (int i = start; i <= end - 1; i++)
		{
			sum += (intensity[i + 1] + intensity[i]) * (time[i + 1] - time[i]) / 2.0;
		}
		return sum - 0.5 * (intensity[end] + intensity[start]) * (time[end] - time[start]);
	}

	private void tsbtnManualPeak_Click(object sender, EventArgs e)
	{
		tsbtnManualPeak.Checked = !tsbtnManualPeak.Checked;
		if (tsbtnManualPeak.Checked)
		{
			if (dgvRegions.SelectedRows != null && dgvRegions.SelectedRows.Count > 0)
			{
				customGraph1.selectRegion = regions[dgvRegions.SelectedRows[0].Index];
				regions[dgvRegions.SelectedRows[0].Index].Start = -1.0;
				regions[dgvRegions.SelectedRows[0].Index].End = -1.0;
				customGraph1.Refresh();
			}
			else
			{
				MessageBox.Show("请先选中积分参数", "提示");
				customGraph1.selectRegion = null;
				tsbtnManualPeak.Checked = false;
			}
		}
		else
		{
			customGraph1.selectRegion = null;
		}
	}

	private void toolStripButton1_Click(object sender, EventArgs e)
	{
		customGraph1.RestoreScale(customGraph1.GraphPane);
		IEnumerable<AcqTime> acqinfo = experiment.AcqTimes.Where((AcqTime ai) => ai.SampleId == selectSample.guid);
		if (acqinfo != null && acqinfo.Count() > 0)
		{
			customGraph1.GraphPane.XAxis.Scale.Max = acqinfo.First().Time;
		}
		else
		{
			customGraph1.GraphPane.XAxis.Scale.Max = 140.0;
		}
		customGraph1.GraphPane.AxisChange();
		customGraph1.Refresh();
	}

	private void toolStripButton2_Click(object sender, EventArgs e)
	{
		tsbtnShowPoints.Checked = !tsbtnShowPoints.Checked;
		customGraph1.IsShowCursorValues = (sender as ToolStripButton).Checked;
	}

	private void toolStripButton3_Click(object sender, EventArgs e)
	{
		customGraph1.Copy(isShowMessage: true);
	}

	private void customGraph1_MouseDoubleClick(object sender, MouseEventArgs e)
	{
	}

	private void dgvRegions_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
	{
		int columnIndex = e.ColumnIndex;
		int num = columnIndex;
		if ((uint)(num - 1) <= 5u)
		{
			if ((double)e.Value > 0.0)
			{
				e.Value = $"{e.Value:F3}";
			}
			else
			{
				e.Value = "";
			}
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Expected O, but got Unknown
		this.components = new System.ComponentModel.Container();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ICP_MS.Plugin.HPLC.FormScan));
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
		this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
		this.groupBox3 = new System.Windows.Forms.GroupBox();
		this.dgvPeak = new System.Windows.Forms.DataGridView();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.dgvRegions = new System.Windows.Forms.DataGridView();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.treeView1 = new System.Windows.Forms.TreeView();
		this.panel1 = new System.Windows.Forms.Panel();
		this.toolStrip1 = new System.Windows.Forms.ToolStrip();
		this.tsbtnAutoPeak = new System.Windows.Forms.ToolStripButton();
		this.tsbtnManualPeak = new System.Windows.Forms.ToolStripButton();
		this.tsbtnRestore = new System.Windows.Forms.ToolStripButton();
		this.tsbtnShowPoints = new System.Windows.Forms.ToolStripButton();
		this.tsbtnCopy = new System.Windows.Forms.ToolStripButton();
		this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dgvSample = new DbufferGrid();
		this.ColSampleName = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colTimes = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colSweeps = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colSymbol = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colDwell = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colResolution = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colLabel = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColPeakPosition = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colStart = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colEnd = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colReference = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.clPeakArea = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColPeakValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.customGraph1 = new ICP_MS.Plugin.HPLC.CustomGraph();
		this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.tableLayoutPanel2.SuspendLayout();
		this.groupBox3.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvPeak).BeginInit();
		this.groupBox2.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvRegions).BeginInit();
		this.groupBox1.SuspendLayout();
		this.panel1.SuspendLayout();
		this.toolStrip1.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvSample).BeginInit();
		base.SuspendLayout();
		this.tableLayoutPanel2.ColumnCount = 3;
		this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 402f));
		this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 209f));
		this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.tableLayoutPanel2.Controls.Add((System.Windows.Forms.Control)(object)this.dgvSample, 0, 2);
		this.tableLayoutPanel2.Controls.Add(this.groupBox3, 0, 0);
		this.tableLayoutPanel2.Controls.Add(this.groupBox2, 2, 0);
		this.tableLayoutPanel2.Controls.Add(this.groupBox1, 1, 0);
		this.tableLayoutPanel2.Controls.Add(this.panel1, 2, 1);
		this.tableLayoutPanel2.Controls.Add(this.customGraph1, 2, 2);
		this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
		this.tableLayoutPanel2.Name = "tableLayoutPanel2";
		this.tableLayoutPanel2.RowCount = 3;
		this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 38f));
		this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 449f));
		this.tableLayoutPanel2.Size = new System.Drawing.Size(1333, 730);
		this.tableLayoutPanel2.TabIndex = 1;
		this.groupBox3.Controls.Add(this.dgvPeak);
		this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
		this.groupBox3.Location = new System.Drawing.Point(4, 4);
		this.groupBox3.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox3.Name = "groupBox3";
		this.groupBox3.Padding = new System.Windows.Forms.Padding(4);
		this.tableLayoutPanel2.SetRowSpan(this.groupBox3, 2);
		this.groupBox3.Size = new System.Drawing.Size(394, 273);
		this.groupBox3.TabIndex = 0;
		this.groupBox3.TabStop = false;
		this.groupBox3.Text = "扫描参数";
		this.dgvPeak.AllowUserToAddRows = false;
		this.dgvPeak.AllowUserToDeleteRows = false;
		dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvPeak.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
		this.dgvPeak.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dgvPeak.Columns.AddRange(this.colSymbol, this.colDwell, this.colResolution);
		dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.dgvPeak.DefaultCellStyle = dataGridViewCellStyle6;
		this.dgvPeak.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvPeak.Location = new System.Drawing.Point(4, 22);
		this.dgvPeak.Margin = new System.Windows.Forms.Padding(4);
		this.dgvPeak.Name = "dgvPeak";
		dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvPeak.RowHeadersDefaultCellStyle = dataGridViewCellStyle7;
		this.dgvPeak.RowHeadersWidth = 51;
		this.dgvPeak.RowTemplate.Height = 23;
		this.dgvPeak.Size = new System.Drawing.Size(386, 247);
		this.dgvPeak.TabIndex = 0;
		this.groupBox2.Controls.Add(this.dgvRegions);
		this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
		this.groupBox2.Location = new System.Drawing.Point(615, 4);
		this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
		this.groupBox2.Size = new System.Drawing.Size(714, 235);
		this.groupBox2.TabIndex = 0;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "积分区间";
		this.dgvRegions.AllowUserToAddRows = false;
		this.dgvRegions.AllowUserToDeleteRows = false;
		dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvRegions.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8;
		this.dgvRegions.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dgvRegions.Columns.AddRange(this.colLabel, this.ColPeakPosition, this.colStart, this.colEnd, this.colReference, this.clPeakArea, this.ColPeakValue);
		dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.dgvRegions.DefaultCellStyle = dataGridViewCellStyle9;
		this.dgvRegions.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvRegions.Location = new System.Drawing.Point(4, 22);
		this.dgvRegions.Margin = new System.Windows.Forms.Padding(4);
		this.dgvRegions.Name = "dgvRegions";
		dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvRegions.RowHeadersDefaultCellStyle = dataGridViewCellStyle10;
		this.dgvRegions.RowHeadersWidth = 51;
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dgvRegions.RowsDefaultCellStyle = dataGridViewCellStyle2;
		this.dgvRegions.RowTemplate.Height = 23;
		this.dgvRegions.Size = new System.Drawing.Size(706, 209);
		this.dgvRegions.TabIndex = 0;
		this.dgvRegions.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(dgvRegions_CellFormatting);
		this.dgvRegions.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(dgvRegions_CellValueChanged);
		this.dgvRegions.MouseDown += new System.Windows.Forms.MouseEventHandler(dgvRegions_MouseDown);
		this.groupBox1.Controls.Add(this.treeView1);
		this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.groupBox1.Location = new System.Drawing.Point(406, 4);
		this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
		this.tableLayoutPanel2.SetRowSpan(this.groupBox1, 3);
		this.groupBox1.Size = new System.Drawing.Size(201, 722);
		this.groupBox1.TabIndex = 0;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "样品/元素";
		this.treeView1.BackColor = System.Drawing.SystemColors.ControlLightLight;
		this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.treeView1.Location = new System.Drawing.Point(4, 22);
		this.treeView1.Margin = new System.Windows.Forms.Padding(4);
		this.treeView1.Name = "treeView1";
		this.treeView1.Size = new System.Drawing.Size(193, 696);
		this.treeView1.TabIndex = 1;
		this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeView1_AfterSelect);
		this.panel1.Controls.Add(this.toolStrip1);
		this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panel1.Location = new System.Drawing.Point(614, 246);
		this.panel1.Name = "panel1";
		this.panel1.Size = new System.Drawing.Size(716, 32);
		this.panel1.TabIndex = 2;
		this.toolStrip1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
		this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[5] { this.tsbtnAutoPeak, this.tsbtnManualPeak, this.tsbtnRestore, this.tsbtnShowPoints, this.tsbtnCopy });
		this.toolStrip1.Location = new System.Drawing.Point(0, 0);
		this.toolStrip1.Name = "toolStrip1";
		this.toolStrip1.Size = new System.Drawing.Size(716, 32);
		this.toolStrip1.TabIndex = 0;
		this.toolStrip1.Text = "toolStrip1";
		this.tsbtnAutoPeak.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnAutoPeak.Image = (System.Drawing.Image)resources.GetObject("tsbtnAutoPeak.Image");
		this.tsbtnAutoPeak.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnAutoPeak.Name = "tsbtnAutoPeak";
		this.tsbtnAutoPeak.Size = new System.Drawing.Size(73, 29);
		this.tsbtnAutoPeak.Text = "自动寻峰";
		this.tsbtnAutoPeak.Click += new System.EventHandler(tsbtnAutoPeak_Click);
		this.tsbtnManualPeak.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnManualPeak.Image = (System.Drawing.Image)resources.GetObject("tsbtnManualPeak.Image");
		this.tsbtnManualPeak.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnManualPeak.Name = "tsbtnManualPeak";
		this.tsbtnManualPeak.Size = new System.Drawing.Size(73, 29);
		this.tsbtnManualPeak.Text = "手动寻峰";
		this.tsbtnManualPeak.Click += new System.EventHandler(tsbtnManualPeak_Click);
		this.tsbtnRestore.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnRestore.Image = (System.Drawing.Image)resources.GetObject("tsbtnRestore.Image");
		this.tsbtnRestore.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnRestore.Name = "tsbtnRestore";
		this.tsbtnRestore.Size = new System.Drawing.Size(73, 29);
		this.tsbtnRestore.Text = "复原图像";
		this.tsbtnRestore.Click += new System.EventHandler(toolStripButton1_Click);
		this.tsbtnShowPoints.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnShowPoints.Image = (System.Drawing.Image)resources.GetObject("tsbtnShowPoints.Image");
		this.tsbtnShowPoints.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnShowPoints.Name = "tsbtnShowPoints";
		this.tsbtnShowPoints.Size = new System.Drawing.Size(103, 29);
		this.tsbtnShowPoints.Text = "显示节点数值";
		this.tsbtnShowPoints.Click += new System.EventHandler(toolStripButton2_Click);
		this.tsbtnCopy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnCopy.Image = (System.Drawing.Image)resources.GetObject("tsbtnCopy.Image");
		this.tsbtnCopy.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnCopy.Name = "tsbtnCopy";
		this.tsbtnCopy.Size = new System.Drawing.Size(73, 29);
		this.tsbtnCopy.Text = "复制图像";
		this.tsbtnCopy.Click += new System.EventHandler(toolStripButton3_Click);
		this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn1.DataPropertyName = "start";
		this.dataGridViewTextBoxColumn1.HeaderText = "起始值";
		this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
		this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn2.DataPropertyName = "end";
		this.dataGridViewTextBoxColumn2.HeaderText = "终止值";
		this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
		this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn3.DataPropertyName = "dwell";
		this.dataGridViewTextBoxColumn3.HeaderText = "驻留时间";
		this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
		this.dataGridViewTextBoxColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn4.DataPropertyName = "channels";
		this.dataGridViewTextBoxColumn4.HeaderText = "通道";
		this.dataGridViewTextBoxColumn4.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
		this.dataGridViewTextBoxColumn5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn5.DataPropertyName = "resolution";
		this.dataGridViewTextBoxColumn5.HeaderText = "分辨率";
		this.dataGridViewTextBoxColumn5.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
		this.dataGridViewTextBoxColumn5.ReadOnly = true;
		this.dataGridViewTextBoxColumn5.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn6.DataPropertyName = "settings";
		this.dataGridViewTextBoxColumn6.HeaderText = "仪器设置";
		this.dataGridViewTextBoxColumn6.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
		this.dataGridViewTextBoxColumn6.ReadOnly = true;
		this.dataGridViewTextBoxColumn6.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.dataGridViewTextBoxColumn6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn7.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn7.DataPropertyName = "start";
		this.dataGridViewTextBoxColumn7.HeaderText = "起始值";
		this.dataGridViewTextBoxColumn7.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
		this.dataGridViewTextBoxColumn7.ReadOnly = true;
		this.dataGridViewTextBoxColumn7.Visible = false;
		this.dataGridViewTextBoxColumn8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn8.DataPropertyName = "end";
		this.dataGridViewTextBoxColumn8.HeaderText = "终止值";
		this.dataGridViewTextBoxColumn8.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
		this.dataGridViewTextBoxColumn8.Visible = false;
		this.dataGridViewTextBoxColumn9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn9.DataPropertyName = "dwell";
		this.dataGridViewTextBoxColumn9.HeaderText = "驻留时间";
		this.dataGridViewTextBoxColumn9.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
		this.dataGridViewTextBoxColumn9.ReadOnly = true;
		this.dataGridViewTextBoxColumn10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn10.DataPropertyName = "channels";
		this.dataGridViewTextBoxColumn10.HeaderText = "通道";
		this.dataGridViewTextBoxColumn10.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
		this.dataGridViewTextBoxColumn10.ReadOnly = true;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).AllowUserToAddRows = false;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).AllowUserToDeleteRows = false;
		dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).Columns.AddRange(this.ColSampleName, this.colTimes, this.colSweeps);
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).DefaultCellStyle = dataGridViewCellStyle3;
		((System.Windows.Forms.Control)(object)this.dgvSample).Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvSample.HorCopy = false;
		((System.Windows.Forms.Control)(object)this.dgvSample).Location = new System.Drawing.Point(4, 285);
		((System.Windows.Forms.Control)(object)this.dgvSample).Margin = new System.Windows.Forms.Padding(4);
		((System.Windows.Forms.Control)(object)this.dgvSample).Name = "dgvSample";
		dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).RowHeadersWidth = 51;
		((System.Windows.Forms.DataGridView)(object)this.dgvSample).RowTemplate.Height = 23;
		((System.Windows.Forms.Control)(object)this.dgvSample).Size = new System.Drawing.Size(394, 441);
		((System.Windows.Forms.Control)(object)this.dgvSample).TabIndex = 1;
		this.dgvSample.VerCopy = true;
		this.ColSampleName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.ColSampleName.DataPropertyName = "SampleName";
		this.ColSampleName.HeaderText = "样品名称";
		this.ColSampleName.MinimumWidth = 6;
		this.ColSampleName.Name = "ColSampleName";
		this.colTimes.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colTimes.DataPropertyName = "Time";
		this.colTimes.HeaderText = "采样时间";
		this.colTimes.MinimumWidth = 6;
		this.colTimes.Name = "colTimes";
		this.colSweeps.DataPropertyName = "Sweeps";
		this.colSweeps.HeaderText = "叠加次数";
		this.colSweeps.MinimumWidth = 6;
		this.colSweeps.Name = "colSweeps";
		this.colSweeps.Width = 125;
		this.colSymbol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colSymbol.DataPropertyName = "symbol";
		this.colSymbol.HeaderText = "元素";
		this.colSymbol.MinimumWidth = 6;
		this.colSymbol.Name = "colSymbol";
		this.colDwell.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colDwell.DataPropertyName = "dwell";
		this.colDwell.HeaderText = "驻留时间";
		this.colDwell.MinimumWidth = 6;
		this.colDwell.Name = "colDwell";
		this.colResolution.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colResolution.DataPropertyName = "resolution";
		this.colResolution.HeaderText = "分辨率";
		this.colResolution.MinimumWidth = 6;
		this.colResolution.Name = "colResolution";
		this.colLabel.DataPropertyName = "Label";
		this.colLabel.HeaderText = "标签";
		this.colLabel.MinimumWidth = 6;
		this.colLabel.Name = "colLabel";
		this.colLabel.Width = 125;
		this.ColPeakPosition.DataPropertyName = "PeakPostion";
		this.ColPeakPosition.HeaderText = "保留时间";
		this.ColPeakPosition.MinimumWidth = 6;
		this.ColPeakPosition.Name = "ColPeakPosition";
		this.ColPeakPosition.ReadOnly = true;
		this.ColPeakPosition.Width = 125;
		this.colStart.DataPropertyName = "Start";
		this.colStart.HeaderText = "起始";
		this.colStart.MinimumWidth = 6;
		this.colStart.Name = "colStart";
		this.colStart.ReadOnly = true;
		this.colStart.Width = 125;
		this.colEnd.DataPropertyName = "End";
		this.colEnd.HeaderText = "结束";
		this.colEnd.MinimumWidth = 6;
		this.colEnd.Name = "colEnd";
		this.colEnd.ReadOnly = true;
		this.colEnd.Width = 125;
		this.colReference.DataPropertyName = "ReferenceId";
		this.colReference.HeaderText = "基底";
		this.colReference.MinimumWidth = 6;
		this.colReference.Name = "colReference";
		this.colReference.Visible = false;
		this.colReference.Width = 125;
		this.clPeakArea.DataPropertyName = "Area";
		this.clPeakArea.HeaderText = "峰面积";
		this.clPeakArea.MinimumWidth = 6;
		this.clPeakArea.Name = "clPeakArea";
		this.clPeakArea.ReadOnly = true;
		this.clPeakArea.Width = 125;
		this.ColPeakValue.DataPropertyName = "Peak";
		this.ColPeakValue.HeaderText = "峰高";
		this.ColPeakValue.MinimumWidth = 6;
		this.ColPeakValue.Name = "ColPeakValue";
		this.ColPeakValue.ReadOnly = true;
		this.ColPeakValue.Width = 125;
		this.customGraph1.AutoSize = true;
		this.customGraph1.Location = new System.Drawing.Point(615, 284);
		this.customGraph1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
		this.customGraph1.Name = "customGraph1";
		this.customGraph1.ScrollGrace = 0.0;
		this.customGraph1.ScrollMaxX = 0.0;
		this.customGraph1.ScrollMaxY = 0.0;
		this.customGraph1.ScrollMaxY2 = 0.0;
		this.customGraph1.ScrollMinX = 0.0;
		this.customGraph1.ScrollMinY = 0.0;
		this.customGraph1.ScrollMinY2 = 0.0;
		this.customGraph1.Size = new System.Drawing.Size(0, 0);
		this.customGraph1.TabIndex = 3;
		this.dataGridViewTextBoxColumn11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn11.DataPropertyName = "resolution";
		this.dataGridViewTextBoxColumn11.HeaderText = "分辨率";
		this.dataGridViewTextBoxColumn11.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
		this.dataGridViewTextBoxColumn12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn12.DataPropertyName = "settings";
		this.dataGridViewTextBoxColumn12.HeaderText = "仪器设置";
		this.dataGridViewTextBoxColumn12.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn12.Name = "dataGridViewTextBoxColumn12";
		this.dataGridViewTextBoxColumn13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn13.DataPropertyName = "symbol";
		this.dataGridViewTextBoxColumn13.HeaderText = "符号";
		this.dataGridViewTextBoxColumn13.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn13.Name = "dataGridViewTextBoxColumn13";
		this.dataGridViewTextBoxColumn13.ReadOnly = true;
		this.dataGridViewTextBoxColumn14.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn14.DataPropertyName = "dwell";
		this.dataGridViewTextBoxColumn14.HeaderText = "驻留时间";
		this.dataGridViewTextBoxColumn14.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn14.Name = "dataGridViewTextBoxColumn14";
		this.dataGridViewTextBoxColumn15.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn15.DataPropertyName = "channels";
		this.dataGridViewTextBoxColumn15.HeaderText = "通道";
		this.dataGridViewTextBoxColumn15.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn15.Name = "dataGridViewTextBoxColumn15";
		this.dataGridViewTextBoxColumn16.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn16.DataPropertyName = "separation";
		this.dataGridViewTextBoxColumn16.HeaderText = "AMU间隔";
		this.dataGridViewTextBoxColumn16.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn16.Name = "dataGridViewTextBoxColumn16";
		this.dataGridViewTextBoxColumn17.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn17.DataPropertyName = "resolution";
		this.dataGridViewTextBoxColumn17.HeaderText = "分辨率";
		this.dataGridViewTextBoxColumn17.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn17.Name = "dataGridViewTextBoxColumn17";
		this.dataGridViewTextBoxColumn18.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn18.DataPropertyName = "settings";
		this.dataGridViewTextBoxColumn18.HeaderText = "仪器设置";
		this.dataGridViewTextBoxColumn18.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn18.Name = "dataGridViewTextBoxColumn18";
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1333, 730);
		base.Controls.Add(this.tableLayoutPanel2);
		base.Margin = new System.Windows.Forms.Padding(4);
		base.Name = "FormScan";
		base.ShowIcon = false;
		this.Text = "FormScan";
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormScan_FormClosing);
		base.Load += new System.EventHandler(FormScan_Load);
		this.tableLayoutPanel2.ResumeLayout(false);
		this.tableLayoutPanel2.PerformLayout();
		this.groupBox3.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dgvPeak).EndInit();
		this.groupBox2.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dgvRegions).EndInit();
		this.groupBox1.ResumeLayout(false);
		this.panel1.ResumeLayout(false);
		this.panel1.PerformLayout();
		this.toolStrip1.ResumeLayout(false);
		this.toolStrip1.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvSample).EndInit();
		base.ResumeLayout(false);
	}
}
